<?php

namespace App\Http\Middleware;

use Closure;

class DisableSessionMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $path = $request->path();
        if (in_array($path, ['wechat/api', '/', ''])) {
            config()->set('session.driver', 'array');
        }
        if (strlen($path) > 2 && substr($path, 0, 2) == 's/') {
            config()->set('session.driver', 'array');
        }
        return $next($request);
    }
}
